<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en" class="no-js">

<head>
    <meta charset="utf-8">
    <title>巨赢网络多开管理后台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- CSS -->
    <link rel="stylesheet" href="/static/jquery-login-20150514/css/reset.css">
    <link rel="stylesheet" href="/static/jquery-login-20150514/css/supersized.css">
    <link rel="stylesheet" href="/static/jquery-login-20150514/css/style.css">

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>

    <title>巨赢多开网络管理后台</title>
    <c:set var="ctx" value="${pageContext.request.contextPath}"/>
    <!-- DataTables CSS -->
    <link rel="stylesheet" type="text/css" href="/static/DataTables-1.10.15/media/css/jquery.dataTables.css">
    <!-- jQuery -->
    <script type="text/javascript" charset="utf8" src="/static/DataTables-1.10.15/media/js/jquery.js"></script>
    <!-- DataTables -->
    <script type="text/javascript" charset="utf8" src="/static/DataTables-1.10.15/media/js/jquery.dataTables.js"></script>
</head>

<body oncontextmenu="return false">

<div class="page-container">
    <h1>巨赢网络多开管理后台</h1>
    <form id="loginForm" action="${ctx}login" method="post" enctype=”multipart/form-data”>
        <div>
            <input type="text" id="username" name="username" class="username" placeholder="用户名" autocomplete="off"/>
        </div>
        <div>
            <input type="password" id="password" name="password" class="password" placeholder="密码" oncontextmenu="return false" onpaste="return false" />
        </div>
        <button id="submit1" type="button">登录</button>
    </form>
    <div class="connect">
        <p>Copyright©2003-2017 ALL Rights Reserved</p>
        <p style="margin-top:20px;">巨赢网络 版权所有 粤ICP备15023058号</p>
    </div>
</div>
<div class="alert" style="display:none">
    <h2>消息</h2>
    <div class="alert_con">
        <p id="ts"></p>
        <p style="line-height:70px"><a class="btn" onclick="closeTab()">确定</a></p>
    </div>
</div>
</body>

<!-- Javascript -->
<script src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="/static/jquery-login-20150514/js/supersized.3.2.7.min.js"></script>
<script src="/static/jquery-login-20150514/js/supersized-init.js"></script>

<script>
    $(".btn").click(function(){
        is_hide();
    })
    var u = $("input[name=username]");
    var p = $("input[name=password]");
    $("#submit1").live('click',function(){
        if(u.val() == '' || p.val() =='')
        {
            $("#ts").html("用户名或密码不能为空");
            is_show();
            return false;
        }else{
            var reg = /^[0-9A-Za-z]+$/;
            if(!reg.exec(u.val()))
            {
                $("#ts").html("用户名错误");
                is_show();
                return false;
            }else{
                //后台提交ajax 成功则true，否则false
                var status = false;
                var username = $("#username").val();
                var password = $("#password").val();
                $.ajax({
                    type: "POST",
                    url: "${ctx}/testLogin",
                    data: {username:username,password:password},
                    dataType: "json",
                    async: false,
                    success: function(result){
                        if(result.success==1){
                            status = true;
                        }else{
                            status = false;
                            $("#ts").html("用户名或密码错误");
                            is_show();
                            return false;
                        }
                    },
                    error: function(result) {
                        status = false;
                        $("#ts").html("用户名或密码错误");
                        is_show();
                        return false;
                    }
                });
                if(status){
                    $("#loginForm").submit();
                }
            }
        }
    });
    window.onload = function()
    {
        $(".connect p").eq(0).animate({"left":"0%"}, 600);
        $(".connect p").eq(1).animate({"left":"0%"}, 400);
    }
    function is_hide(){ $(".alert").animate({"top":"-40%"}, 300) }
    function is_show(){ $(".alert").show().animate({"top":"45%"}, 300) }
    function closeTab(){
        is_hide();
    }

</script>

</html>

